- return if Gitlab.org_or_com?
- return unless License.feature_available?(:code_suggestions)

- expanded = integration_expanded?('ai_access')

%section.settings.no-animate#js-ai-access-settings{ class: ('expanded' if expanded) }
  .settings-header
    %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only
      = s_('CodeSuggestionsSM|Code Suggestions')
    = render Pajamas::ButtonComponent.new(button_options: { class: 'js-settings-toggle' }) do
      = expanded ? _('Collapse') : _('Expand')
    %p.gl-text-secondary
      = code_suggestions_description

  .settings-content
    = gitlab_ui_form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-ai-access-settings'), html: { class: 'fieldset-form', id: 'ai-access-settings' } do |f|
      = form_errors(@application_setting)

      %fieldset
        .form-group
          = f.gitlab_ui_checkbox_component :instance_level_code_suggestions_enabled,
            s_('CodeSuggestionsSM|Enable Code Suggestions for this instance %{beta}').html_safe % { beta: gl_badge_tag(_('Beta'), variant: :neutral, size: :sm) },
            help_text: code_suggestions_agreement

      = f.submit _('Save changes'), pajamas_button: true
